package com.qiyebox.web.controller.biz;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qiyebox.common.annotation.Log;
import com.qiyebox.common.enums.BusinessType;
import com.qiyebox.system.domain.MeetingMemo;
import com.qiyebox.system.service.IMeetingMemoService;
import com.qiyebox.common.core.controller.BaseController;
import com.qiyebox.common.core.domain.AjaxResult;
import com.qiyebox.common.utils.poi.ExcelUtil;
import com.qiyebox.common.core.page.TableDataInfo;

/**
 * 会议纪要Controller
 * 
 * @author qiyebox
 * @date 2025-02-14
 */
@Controller
@RequestMapping("/system/memo")
public class MeetingMemoController extends BaseController
{
    private String prefix = "system/memo";

    @Autowired
    private IMeetingMemoService meetingMemoService;

    @RequiresPermissions("system:memo:view")
    @GetMapping()
    public String memo()
    {
        return prefix + "/memo";
    }

    /**
     * 查询会议纪要列表
     */
    @RequiresPermissions("system:memo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MeetingMemo meetingMemo)
    {
        startPage();
        List<MeetingMemo> list = meetingMemoService.selectMeetingMemoList(meetingMemo);
        return getDataTable(list);
    }

    /**
     * 导出会议纪要列表
     */
    @RequiresPermissions("system:memo:export")
    @Log(title = "会议纪要", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MeetingMemo meetingMemo)
    {
        List<MeetingMemo> list = meetingMemoService.selectMeetingMemoList(meetingMemo);
        ExcelUtil<MeetingMemo> util = new ExcelUtil<MeetingMemo>(MeetingMemo.class);
        return util.exportExcel(list, "会议纪要数据");
    }

    /**
     * 新增会议纪要
     */
    @RequiresPermissions("system:memo:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会议纪要
     */
    @RequiresPermissions("system:memo:add")
    @Log(title = "会议纪要", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MeetingMemo meetingMemo)
    {
        return toAjax(meetingMemoService.insertMeetingMemo(meetingMemo));
    }

    /**
     * 修改会议纪要
     */
    @RequiresPermissions("system:memo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MeetingMemo meetingMemo = meetingMemoService.selectMeetingMemoById(id);
        mmap.put("meetingMemo", meetingMemo);
        return prefix + "/edit";
    }

    /**
     * 修改保存会议纪要
     */
    @RequiresPermissions("system:memo:edit")
    @Log(title = "会议纪要", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MeetingMemo meetingMemo)
    {
        return toAjax(meetingMemoService.updateMeetingMemo(meetingMemo));
    }

    /**
     * 删除会议纪要
     */
    @RequiresPermissions("system:memo:remove")
    @Log(title = "会议纪要", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(meetingMemoService.deleteMeetingMemoByIds(ids));
    }
}
